import Ember from 'ember';

export default Ember.Mixin.create({
  _patch: Ember.A(),
  trueDirty: Ember.computed("_patch.[]", "model.hasDirtyAttributes", function(){
    return this.get('_patch').length > 0 || this.get('model').get('hasDirtyAttributes');
  }),
  sumupPatch() {
    var model = this.get('model'),
        fns = Object.keys(model.changedAttributes()),
        patch = fns.concat(this.get('_patch')).uniq().filter((it) => {
          return it.indexOf("__") !== 0;
      });
      model.set('_patch', patch);
  }
});
